import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'splash_logic.dart';

/// 闪屏页面视图 - Splash Screen View
///
/// 应用启动时的闪屏页面，包含跳过按钮和倒计时功能
/// Splash screen displayed on app startup with skip button and countdown
class SplashView extends StatelessWidget {
  const SplashView({super.key});

  @override
  Widget build(BuildContext context) {
    // GetBuilder作为最外层包裹Widget - GetBuilder as the outermost wrapper widget
    // 每个View中只能有一个GetBuilder - Only one GetBuilder per View
    return GetBuilder<SplashLogic>(
      init: SplashLogic(),
      builder: (logic) {
        return Scaffold(
          backgroundColor: Colors.blue.shade50,
          body: Stack(
            children: [
              // 主要内容区域 - Main Content Area
              Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    // 应用图标 - App Icon
                    Container(
                      width: 120,
                      height: 120,
                      decoration: BoxDecoration(
                        color: Colors.blue,
                        borderRadius: BorderRadius.circular(20),
                        boxShadow: [
                          BoxShadow(
                            color: Colors.blue.withOpacity(0.3),
                            blurRadius: 20,
                            offset: const Offset(0, 10),
                          ),
                        ],
                      ),
                      child: const Icon(
                        Icons.description,
                        size: 60,
                        color: Colors.white,
                      ),
                    ),

                    const SizedBox(height: 32),

                    // 应用名称 - App Name
                    const Text(
                      'Prompt Manager',
                      style: TextStyle(
                        fontSize: 28,
                        fontWeight: FontWeight.bold,
                        color: Colors.blue,
                      ),
                    ),

                    const SizedBox(height: 16),

                    // 应用描述 - App Description
                    Text(
                      '智能 Prompt 管理工具',
                      style: TextStyle(
                        fontSize: 16,
                        color: Colors.grey.shade600,
                      ),
                    ),

                    const SizedBox(height: 48),

                    // 加载指示器 - Loading Indicator
                    SizedBox(
                      width: 40,
                      height: 40,
                      child: CircularProgressIndicator(
                        strokeWidth: 3,
                        valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
                      ),
                    ),
                  ],
                ),
              ),

              // 右上角跳过按钮和倒计时 - Skip Button and Countdown in Top Right
              Positioned(
                top: MediaQuery.of(context).padding.top + 16,
                right: 16,
                child: Container(
                  padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
                  decoration: BoxDecoration(
                    color: Colors.white.withOpacity(0.9),
                    borderRadius: BorderRadius.circular(20),
                    boxShadow: [
                      BoxShadow(
                        color: Colors.black.withOpacity(0.1),
                        blurRadius: 8,
                        offset: const Offset(0, 2),
                      ),
                    ],
                  ),
                  child: Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      // 倒计时显示 - Countdown Display
                      Text(
                        '${logic.state.countdown}s',
                        style: const TextStyle(
                          fontSize: 14,
                          fontWeight: FontWeight.w500,
                          color: Colors.blue,
                        ),
                      ),

                      const SizedBox(width: 8),

                      // 跳过按钮 - Skip Button
                      GestureDetector(
                        onTap: logic.skipSplash,
                        child: Container(
                          padding: const EdgeInsets.symmetric(
                            horizontal: 12,
                            vertical: 4,
                          ),
                          decoration: BoxDecoration(
                            color: Colors.blue,
                            borderRadius: BorderRadius.circular(12),
                          ),
                          child: const Text(
                            '跳过',
                            style: TextStyle(
                              fontSize: 12,
                              fontWeight: FontWeight.w500,
                              color: Colors.white,
                            ),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        );
      },
    );
  }
}